﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WaveMaster.Holidays.Club.Service;
using System.Configuration;
using System.Net;
using System.Collections;
using System.Data;
using CrystalDecisions.CrystalReports.Engine;
using System.Windows.Forms;

namespace WaveMaster.Holidays.Club.ServiceClient
{
    class Program
    {
        private static System.Timers.Timer aTimer;
        private static ReportRequestService m_ReportRequestService;

        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new PrinterMonitoringForm());
        }

        //static void Main(string[] args)
        //{
        //    aTimer = new System.Timers.Timer(3000);
        //    aTimer.Elapsed += new System.Timers.ElapsedEventHandler(aTimer_Elapsed);
        //    aTimer.Enabled = true;

        //    while (true)
        //    { }
        //}

        //static void aTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        //{
        //    try
        //    {
        //        string url = ConfigurationManager.AppSettings["URLServer"];
        //        m_ReportRequestService = Activator.GetObject(typeof(ReportRequestService), url) as ReportRequestService;


        //        string strHostName = System.Net.Dns.GetHostName(); ;
        //        IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName);
        //        IPAddress[] addr = ipEntry.AddressList;
        //        string ipaddress = addr[addr.Length - 1].ToString();
        //        if (ipaddress == "") { Console.WriteLine("IP notdetected"); return; }

        //        IList reportBPdatas = m_ReportRequestService.GetBoardingPassRequestReportByIPAddress(ipaddress);
        //        string printerBP = ConfigurationManager.AppSettings["BoardingPassPrinterName"];
        //        string reportSourceBP = ConfigurationManager.AppSettings["BoardingPassReportFile"];
        //        foreach (DataSet bp in reportBPdatas)
        //        {
        //            ReportDocument rpdoc = new ReportDocument();
        //            rpdoc.Load(reportSourceBP);
        //            rpdoc.SetDataSource(bp);
        //            rpdoc.PrintOptions.PrinterName = printerBP;
        //            rpdoc.PrintToPrinter(1, false, 1, 1);
        //        }

        //        IList reportWCdatas = m_ReportRequestService.GetWhiteCardRequestReportByIPAddress(ipaddress);
        //        string printerWC = ConfigurationManager.AppSettings["WhiteCardPrinterName"];
        //        string reportSourceWC = ConfigurationManager.AppSettings["WhiteCardReportFile"];
        //        foreach (DataSet wc in reportWCdatas)
        //        {
        //            ReportDocument rpdoc = new ReportDocument();
        //            rpdoc.Load(reportSourceWC);
        //            rpdoc.SetDataSource(wc);
        //            rpdoc.PrintOptions.PrinterName = printerWC;
        //            rpdoc.PrintToPrinter(1, false, 1, 1);
        //        }
        //    }
        //    catch (Exception x)
        //    {
        //        Console.WriteLine(x.Message);
        //    }
        //}

    }
}
